package com.dankegongyu.lib.list

import android.os.Bundle
import com.dankegongyu.lib.R
import com.dankegongyu.lib.base.BaseAppActivity
import io.reactivex.Observable
import io.reactivex.ObservableEmitter
import io.reactivex.ObservableOnSubscribe
import io.reactivex.Observer
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_horizontalwrappedlist.*
import kotlinx.android.synthetic.main.activity_wraphorizontallinearlistlayout.*

/**
 * @author wpq
 * @version 1.0
 */
class TestHorizontalWrappedListViewActivity : BaseAppActivity() {
    override fun getContentViewLayoutId(): Int {
        return R.layout.activity_horizontalwrappedlist
    }

    override fun init(savedInstanceState: Bundle?) {}
    override fun initPresenter() {}
    override fun doBusiness() {
        val list = mutableListOf<String>()
        for (i in 0..6) {
            list.add("横向显示" + i)
        }
        listView.setAdapter(HorizontalListAdapter(list))

        Observable
                .create(object : ObservableOnSubscribe<String> {
                    override fun subscribe(emitter: ObservableEmitter<String>) {
                        emitter.onNext("")
                    }
                })
                .subscribeOn(Schedulers.io()) // 切换到异步线程绘制
                .compose(bindToLifecycle())
                .subscribe(object : Observer<String?> {
                    override fun onComplete() {
                    }

                    override fun onSubscribe(d: Disposable) {
                    }

                    override fun onNext(t: String) {
                    }

                    override fun onError(e: Throwable) {
                    }
                })
    }
}